package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaAudit;
import com.ruoyi.system.service.IJiajiaAuditService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 微信审核Controller
 *
 * @author ruoyi
 * @date 2025-03-13
 */
@Controller
@RequestMapping("/system/jiajiaAudit")
public class JiajiaAuditController extends BaseController
{
    private String prefix = "system/jiajiaAudit";

    @Autowired
    private IJiajiaAuditService jiajiaAuditService;

    @RequiresPermissions("system:jiajiaAudit:view")
    @GetMapping()
    public String jiajiaAudit()
    {
        return prefix + "/jiajiaAudit";
    }

    /**
     * 查询微信审核列表
     */
    @RequiresPermissions("system:jiajiaAudit:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaAudit jiajiaAudit)
    {
        startPage();
        List<JiajiaAudit> list = jiajiaAuditService.selectJiajiaAuditList(jiajiaAudit);
        return getDataTable(list);
    }

    /**
     * 导出微信审核列表
     */
    @RequiresPermissions("system:jiajiaAudit:export")
    @Log(title = "微信审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaAudit jiajiaAudit)
    {
        List<JiajiaAudit> list = jiajiaAuditService.selectJiajiaAuditList(jiajiaAudit);
        ExcelUtil<JiajiaAudit> util = new ExcelUtil<JiajiaAudit>(JiajiaAudit.class);
        return util.exportExcel(list, "微信审核数据");
    }

    /**
     * 新增微信审核
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存微信审核
     */
    @RequiresPermissions("system:jiajiaAudit:add")
    @Log(title = "微信审核", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaAudit jiajiaAudit)
    {
        return toAjax(jiajiaAuditService.insertJiajiaAudit(jiajiaAudit));
    }

    /**
     * 修改微信审核
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaAudit jiajiaAudit = jiajiaAuditService.selectJiajiaAuditById(id);
        mmap.put("jiajiaAudit", jiajiaAudit);
        return prefix + "/edit";
    }

    /**
     * 修改保存微信审核
     */
    @RequiresPermissions("system:jiajiaAudit:edit")
    @Log(title = "微信审核", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaAudit jiajiaAudit)
    {
        return toAjax(jiajiaAuditService.updateJiajiaAudit(jiajiaAudit));
    }

    /**
     * 删除微信审核
     */
    @RequiresPermissions("system:jiajiaAudit:remove")
    @Log(title = "微信审核", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaAuditService.deleteJiajiaAuditByIds(ids));
    }
}
